﻿
using LPP.Entity;
using LPP.Service.UserReviewService;
using Microsoft.AspNetCore.Mvc;

namespace LPP.API.Controllers
{
    [ApiController]
    [Route("api/[controller]")]
    public class UserReviewController : ControllerBase
    {
        private readonly UserReviewService _userReviewService;

        public UserReviewController(UserReviewService userReviewService)
        {
            _userReviewService = userReviewService;
        }

        [HttpPost]
        public async Task<IActionResult> AddReview([FromBody] UserReview review)
        {
            if (review == null)
            {
                return BadRequest("Review cannot be null.");
            }

            await _userReviewService.AddReviewAsync(review);
            return Ok("Review added successfully.");
        }

        [HttpGet("{userId}")]
        public async Task<IActionResult> GetReviews(int userId)
        {
            var reviews = await _userReviewService.GetReviewsForUserAsync(userId);
            return Ok(reviews);
        }
    }
}

